#ifndef DETCOL_HPP_INCLUDED
#define DETCOL_HPP_INCLUDED
#include "../forcas/forcasResult.h"
#include <omp.h>
#include "../misc/MODEL.H"
#include <iostream>

class SPHERE;
class MODEL;
class LINE;
class LINE_SET;
class ForcaResultante;
template<class T> class ELEMENT_LIST ;
using namespace std;

void ImprimeMem(const char* ca,int mem);

class DetecColisao
{
    protected:
        ELEMENT_LIST<SPHERE>* Spheres;				// Elementos
        long Rows;
        long Cols;
        long Memory; //Máximo de memória
        REAL MinR[2];						// Fronteiras
        REAL MaxR[2];
        //SPHERE **threadEsfera;
        ForcaResultante* Forca;

        inline double Min( double x, double y ) { return (x < y)? x : y; }
        inline double Max( double x, double y ) { return (x > y)? x : y; }


    public:

        DetecColisao() {
            Memory = 0;
            Spheres = NULL;
            MinR[0] = MinR[1] = MaxR[0] = MaxR[1] = 0.0;
            //threadEsfera= new SPHERE*[omp_get_num_procs()];
        }

        ~DetecColisao() {}

        void Set_Elements( ELEMENT_LIST<SPHERE>* spheres) {
            Spheres = spheres;
        }

        virtual void iniciaMatriz( REAL min_r[2], REAL max_r[2] ) {
            MinR[0] = min_r[0];
            MinR[1] = min_r[1];
            MaxR[0] = max_r[0];
            MaxR[1] = max_r[1];
        }
        long Get_Memory() { return Memory; }

        //Calcular TODAS as forcas resultantes das colisões ou Forças de campo
        virtual void calcular()=0;

};


class Linhas : public DetecColisao
{
     private:
            ELEMENT_LIST<LINE>* Lines;
            ELEMENT_LIST<LINE_SET>* Line_set;
            REAL precisao;

     public:
            Linhas(MODEL*md,ForcaResultante* F);
            void calcular();
};



#endif
